#define MyAppName "bird"

[Setup]
AppName={#MyAppName}
AppVersion=0.0.0.0
AppVerName={#MyAppName}
AppPublisher=mad8384671

;
DefaultDirName={pf}\Angry Birds Seasons
DefaultGroupName={#MyAppName}
OutputDir=.

AllowNoIcons=yes

;安装包路径
OutputBaseFilename={#MyAppName}
SetupIconFile=installer.ico
UninstallIconFile=installer.ico

;其他
Compression=lzma/ultra64
SolidCompression=yes
VersionInfoVersion=0.0.0.0
VersionInfoTextVersion=0.0.0.0
VersionInfoDescription={#MyAppName}

;启动
DisableReadyPage=yes
DisableProgramGroupPage=yes
InternalCompressLevel=ultra64
DirExistsWarning=no

[Messages]
SetupAppTitle=

BeveledLabel=Inno Setup Compiler 5.4.2
DiskSpaceMBLabel=所需空间: [mb] MB
ButtonBack=上一步
ButtonNext=下一步
ButtonInstall=立刻安装
ButtonCancel=取消
ButtonFinish=完成
ButtonBrowse=浏览目录
ButtonWizardBrowse=
 
[CustomMessages]
SelectDirLabel=安装路径:
ZidingyiLabel=自定义选项
WelTxt5=1.0  测试版
SelectDirPage=
InstallingPage=
FinishedLabel=恭喜，{#MyAppName}安装成功！
FinishedPage=
FinishedHeadingLabel={#MyAppName} 安装向导完成

[Icons]
Name: {commondesktop}\{#MyAppName}; Filename: {app}\AngryBirdsSeasons.exe; WorkingDir: {app}; Check: Desktop;

[Files]
Source: files\*; DestDir: {tmp}; Flags: dontcopy solidbreak;

[code]
type
	TBtnEventProc = procedure (h:HWND);
	TTimerProc    = procedure(h:longword; msg:longword; idevent:longword; dwTime:longword);
	TPBProc = function(h:hWnd;Msg,wParam,lParam:Longint):Longint;  //百分比
Const
	//鼠标指向
	MyCursor1 = 101;
	MyCursor2 = 102;
//窗口移动
  WM_SYSCOMMAND = $0112;
//卸载
//  WS_EX_APPWINDOW = $40000;
//按钮
  BtnClickEventID      = 1;
  BtnMouseEnterEventID = 2;
  BASS_ACTIVE_PAUSED   = 3;
  BASS_SAMPLE_LOOP     = 4;
//鼠标指向
function LoadCursorFromFile(FileName: String): Cardinal; external 'LoadCursorFromFile{#A}@user32 stdcall';
function DeleteObject(p1: Longword): BOOL; external 'DeleteObject@gdi32.dll stdcall';
//botva2
function ImgLoad(Wnd :HWND; FileName :PAnsiChar; Left, Top, Width, Height :integer; Stretch, IsBkg :boolean) :Longint; external 'ImgLoad@{tmp}\botva2.dll stdcall delayload';
procedure ImgSetVisibility(img :Longint; Visible :boolean); external 'ImgSetVisibility@{tmp}\botva2.dll stdcall delayload';
procedure ImgApplyChanges(h:HWND); external 'ImgApplyChanges@{tmp}\botva2.dll stdcall delayload';
procedure ImgSetPosition(img :Longint; NewLeft, NewTop, NewWidth, NewHeight :integer); external 'ImgSetPosition@files:botva2.dll stdcall';
procedure gdipShutdown;  external 'gdipShutdown@{tmp}\botva2.dll stdcall delayload';
function WrapBtnCallback(Callback: TBtnEventProc; ParamCount: Integer): Longword; external 'wrapcallback@{tmp}\innocallback.dll stdcall delayload';
function BtnCreate(hParent:HWND; Left,Top,Width,Height:integer; FileName:PAnsiChar; ShadowWidth:integer; IsCheckBtn:boolean):HWND;  external 'BtnCreate@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetText(h:HWND; Text:PAnsiChar);  external 'BtnSetText@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetVisibility(h:HWND; Value:boolean); external 'BtnSetVisibility@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetFont(h:HWND; Font:Cardinal); external 'BtnSetFont@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetFontColor(h:HWND; NormalFontColor, FocusedFontColor, PressedFontColor, DisabledFontColor: Cardinal); external 'BtnSetFontColor@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetEvent(h:HWND; EventID:integer; Event:Longword); external 'BtnSetEvent@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetCursor(h:HWND; hCur:Cardinal); external 'BtnSetCursor@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetEnabled(h:HWND; Value:boolean); external 'BtnSetEnabled@{tmp}\botva2.dll stdcall delayload';
function GetSysCursorHandle(id:integer):Cardinal; external 'GetSysCursorHandle@{tmp}\botva2.dll stdcall delayload';
function BtnGetChecked(h:HWND):boolean; external 'BtnGetChecked@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetChecked(h:HWND; Value:boolean); external 'BtnSetChecked@{tmp}\botva2.dll stdcall delayload';
procedure CreateFormFromImage(h:HWND; FileName:PAnsiChar); external 'CreateFormFromImage@{tmp}\botva2.dll stdcall delayload';
//音乐
function BASS_Init(device: Integer; freq, flags: DWORD; win: hwnd; CLSID: Integer): Boolean; external 'BASS_Init@files:BASS.dll stdcall delayload';
function BASS_StreamCreateFile(mem: BOOL; f: PAnsiChar; offset: DWORD; length: DWORD; flags: DWORD): DWORD; external 'BASS_StreamCreateFile@files:BASS.dll stdcall delayload';
function BASS_Start: Boolean; external 'BASS_Start@files:BASS.dll stdcall delayload';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): Boolean; external 'BASS_ChannelPlay@files:BASS.dll stdcall delayload';
function BASS_ChannelIsActive(handle: DWORD): Integer; external 'BASS_ChannelIsActive@files:BASS.dll stdcall delayload';
function BASS_ChannelPause(handle: DWORD): Boolean; external 'BASS_ChannelPause@files:BASS.dll stdcall delayload';
function BASS_Pause: Boolean; external 'BASS_Pause@files:BASS.dll stdcall delayload';
function BASS_Stop: Boolean; external 'BASS_Stop@files:BASS.dll stdcall delayload';
function BASS_Free: Boolean; external 'BASS_Free@files:BASS.dll stdcall delayload';
function sndPlaySound(lpszSoundName: AnsiString; uFlags: cardinal):integer; external 'sndPlaySoundA@winmm.dll stdcall';
//水纹
function WrapTimerProc(callback: TTimerProc; Paramcount: Integer): Longword; external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: LongWord; nIDEvent: LongWord): LongWord; external 'KillTimer@user32.dll stdcall';

//安装过程图片轮播
function NewWebWnd(hWndParent: HWND; X, Y, nWidth, nHeight: Integer): HWND; external 'newwebwnd@files:webctrl.dll stdcall';
function FreeAllWebWnd(): Boolean; external 'freeallwebwnd@files:webctrl.dll stdcall';
function WebWndSetParent(hWndWeb: HWND; hWndParent: HWND): Boolean; external 'webwndsetparent@files:webctrl.dll stdcall';
function DisplayHTMLPage(hWndWeb: HWND; lpsURL: PChar): Boolean; external 'displayhtmlpage@files:webctrl.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function PBCallBack(P:TPBProc;ParamCount:integer):LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam, lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
procedure ImgSetVisiblePart(img:Longint; NewLeft, NewTop, NewWidth, NewHeight : integer); external 'ImgSetVisiblePart@files:botva2.dll stdcall';

//圆角
function CreateRoundRectRgn(p1, p2, p3, p4, p5, p6: Integer): THandle; external 'CreateRoundRectRgn@gdi32 stdcall';
function SetWindowRgn(hWnd: HWND; hRgn: THandle; bRedraw: Boolean): Integer; external 'SetWindowRgn@user32 stdcall';
function ReleaseCapture(): Longint; external 'ReleaseCapture@user32.dll stdcall';

procedure ShapeForm(aForm: TForm; edgeSize: integer);
var
  FormRegion:LongWord;
begin
  FormRegion:=CreateRoundRectRgn(0,0,aForm.Width,aForm.Height,edgeSize+7,edgeSize+7);
  SetWindowRgn(aForm.Handle,FormRegion,True);
end;

var
//鼠标指向
cursor: Cardinal;
UpArrow: Cardinal;
//取消窗口
CancelImage1,CancelImage: Longint;
AboutForm,CancelForm: TSetupForm;
OKButton: TButton;
//空路径窗口
IconI: Longint;
GerenfolderForm: TSetupForm;
OnlinkBtn,mp3Handle: HWND;
ErrorCode: Integer;
WizardFormImage: Longint; //背景图
SelectDirline, Gerenfolderline, Zidingyiline, Finishedline: Longint; //横线
MinBtn,CloseBtn,music,help,IsBtn,CancelCloseBtn,CancelCloseBtn1: HWND; //右上角按钮+取消窗口
CancelBtn, NextBtn, DirBrowseBtn,DirBrowseBtn2,OKBtn,CancelFormBtn: HWND; //按钮
WFButtonFont: TFont;

TimerID2: LongWord;
ImgVsync: Longint;
VsyncTop: integer;

mp3Name:string;

SelectDirLabel,ZidingyiLabe,FinishedLabel: Tlabel;
//目录
//Diredit:TEdit;
Diredit: Tlabel;
//快捷方式选框
licenseCheck,AutoRunCheck,DesktopCheck,StartMenuCheck,Run1Check,Run2Check: HWND;
AutoRunLabel,DesktopLabel,StartMenuLabel,Run1Label,Run2Label: TLabel;
//欢迎协议
Notice: TRichEditViewer;
progressbgImg,progressbgImg1: Longint;
PrLabel,PrLabel1: TLabel;
PBOldProc : Longint;
CancelLabel1,CancelLabel3,CancelLabel2,QZONELabel,QQLabel:Tlabel;
//百分比
function PBProc(h:hWnd;Msg,wParam,lParam:Longint):Longint;
var
  pr,i1,i2 : Extended;
  w : integer;
begin
  Result:=CallWindowProc(PBOldProc,h,Msg,wParam,lParam);
  if (Msg=$402) and (WizardForm.ProgressGauge.Position>WizardForm.ProgressGauge.Min) then begin
    i1:=WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min;
    i2:=WizardForm.ProgressGauge.Max-WizardForm.ProgressGauge.Min;
    pr:=i1*100/i2;
    PrLabel.Caption:=IntToStr(Round(pr))+'%';
    w:=Round(451*pr/100);
    ImgSetPosition(progressbgImg,35,261,w,23);
    //ImgSetVisiblePart(progressbgImg,0,0,w,23);
    ImgApplyChanges(WizardForm.Handle);
  end;
end;

//网站连接
procedure QQOnClick(Sender: TObject);
begin
ShellExec('open', 'http://www.win7new.comcom/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
procedure QZONEOnClick(Sender: TObject);
begin
ShellExec('open', 'http://ioi5201314.qzone.qq.com/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;


//窗口移动
procedure WizardFormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture
  SendMessage(WizardForm.Handle, WM_SYSCOMMAND, $F012, 0)
end;

//取消窗口
procedure CancelFormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture
  SendMessage(CancelForm.Handle, WM_SYSCOMMAND, $F012, 0)
end;
procedure CancelFormMouseDown1(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture
  SendMessage(CancelForm.Handle, WM_SYSCOMMAND, $F012, 0)
end;


//空路径窗口
procedure GerenfolderFormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture
  SendMessage(GerenfolderForm.Handle, WM_SYSCOMMAND, $F012, 0)
end;

procedure GerenfoldeFormCancleBtnOnClick(hBtn:HWND);
begin
GerenfolderForm.close;
end;

procedure GerenfoldeBtnOnClick(hBtn:HWND);
begin
GerenfolderForm.close;
end;

procedure CancelClose1BtnOnClick(hBtn:HWND);
begin
CancelForm.close;
end;

//取消窗口关闭按钮
procedure CancelCloseBtnOnClick(hBtn:HWND);
begin
CancelForm.close;
end;

procedure OKBtnOnClick(hBtn:HWND);
begin
OKButton.Click;
end;

procedure CancelBtnOnClick(hBtn:HWND);
begin
CancelForm.close;
end;

//最小化按钮
procedure MinBtnOnClick(hBtn:HWND);
begin
SendMessage(WizardForm.Handle,WM_SYSCOMMAND,61472,0);
end;
//关闭按钮
procedure CloseBtnOnClick(hBtn:HWND);
begin
WizardForm.Close;
end;

procedure MusicClick(hBtn:HWND);
begin
  sndPlaySound(ExpandConstant('{tmp}\music.wav'), $0001);
  if BtnGetChecked(music) then BASS_ChannelPause(mp3Handle)
    else if BASS_ChannelIsActive(mp3Handle)=BASS_ACTIVE_PAUSED then BASS_ChannelPlay(mp3Handle, False);
end;


procedure helpClick1(hBtn:HWND);//(CurPageID: Integer; var Cancel, Confirm: Boolean);
var
  shang,xia: Longint;
begin
  CancelForm := CreateCustomForm();
  CancelForm.Width := ScaleX(348);
  CancelForm.Height := ScaleY(183);
  CancelForm.Cursor := MyCursor1;
  CancelForm.BorderStyle:=bsNone;
  CancelForm.OnMouseDown:=@CancelFormMouseDown;
  CancelForm.CenterInsideControl(WizardForm, False);
  CancelImage:=ImgLoad(CancelForm.Handle,ExpandConstant('{tmp}\MsgDlgBg.png'),ScaleX(0), ScaleY(0),ScaleY(348),ScaleY(183),True,True);
  CancelImage:=ImgLoad(CancelForm.Handle,ExpandConstant('{tmp}\wen.png'),ScaleX(10), ScaleY(40),ScaleY(326),ScaleY(55),True,True);
  CancelImage:=ImgLoad(CancelForm.Handle,ExpandConstant('{tmp}\wen1.png'),ScaleX(10), ScaleY(90),ScaleY(326),ScaleY(55),True,True);
  //关闭按钮
  CancelCloseBtn:=BtnCreate(CancelForm.Handle,230,132,69,30,ExpandConstant('{tmp}\button1.png'),3,False);
  BtnSetEvent(CancelCloseBtn,BtnClickEventID,WrapBtnCallback(@CancelClose1BtnOnClick,1));
  BtnSetFontColor(CancelCloseBtn,clWhite,clWhite,clWhite,$B6B6B6);
  BtnSetFont(CancelCloseBtn,WFButtonFont.Handle);
  BtnSetText(CancelCloseBtn,ExpandConstant('关闭'));
  BtnSetCursor(CancelCloseBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));

  CancelCloseBtn1:=BtnCreate(CancelForm.Handle,313,5,30,30,ExpandConstant('{tmp}\Close.png'),3,False);
  BtnSetEvent(CancelCloseBtn1,BtnClickEventID,WrapBtnCallback(@CancelClose1BtnOnClick,1));
  BtnSetFont(CancelCloseBtn1,WFButtonFont.Handle);
  BtnSetCursor(CancelCloseBtn1,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));

  OKButton := TButton.Create(CancelForm);
  OKButton.Parent := CancelForm;
  OKButton.ModalResult := mrOk;
  OKButton.SetBounds(0, 0, 0, 0);

  ImgApplyChanges(CancelForm.Handle);

  if CancelForm.ShowModal = mrOK then
  begin
  end
end;

//关于
procedure AboutButtonOnClick1(hBtn:HWND);//(CurPageID: Integer; var Cancel, Confirm: Boolean);
var
  shang,xia: Longint;
begin
  CancelForm := CreateCustomForm();
  CancelForm.Width := ScaleX(348);
  CancelForm.Height := ScaleY(183);
  CancelForm.Cursor := MyCursor1;
  CancelForm.BorderStyle:=bsNone;
  CancelForm.OnMouseDown:=@CancelFormMouseDown;
  CancelForm.CenterInsideControl(WizardForm, False);
  CancelImage:=ImgLoad(CancelForm.Handle,ExpandConstant('{tmp}\MsgDlgBg.png'),ScaleX(0), ScaleY(0),ScaleY(348),ScaleY(183),True,True);
  //关闭按钮
  CancelCloseBtn:=BtnCreate(CancelForm.Handle,230,132,69,30,ExpandConstant('{tmp}\button1.png'),3,False);
  BtnSetEvent(CancelCloseBtn,BtnClickEventID,WrapBtnCallback(@CancelClose1BtnOnClick,1));
  BtnSetFontColor(CancelCloseBtn,clWhite,clWhite,clWhite,$B6B6B6);
  BtnSetFont(CancelCloseBtn,WFButtonFont.Handle);
  BtnSetText(CancelCloseBtn,ExpandConstant('关闭'));
  BtnSetCursor(CancelCloseBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));

  CancelCloseBtn1:=BtnCreate(CancelForm.Handle,313,5,30,30,ExpandConstant('{tmp}\Close.png'),3,False);
  BtnSetEvent(CancelCloseBtn1,BtnClickEventID,WrapBtnCallback(@CancelClose1BtnOnClick,1));
  BtnSetFont(CancelCloseBtn1,WFButtonFont.Handle);
  BtnSetCursor(CancelCloseBtn1,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));

  CancelLabel1:= TLabel.Create(CancelForm);
  CancelLabel1.AutoSize:=False;
  CancelLabel1.Parent:=CancelForm;
  CancelLabel1.Font.Style := [fsBold];
  CancelLabel1.Font.Size := 20
  CancelLabel1.SetBounds(ScaleX(27), ScaleY(33), ScaleY(310), ScaleY(150));
  CancelLabel1.Transparent:=True;
  CancelLabel1.Caption := '愤怒的小鸟 '; //Metro QQ2012
  CancelLabel1.OnMouseDown:=@CancelFormMouseDown;
  CancelLabel1.Font.Name := '微软雅黑';
//  CancelLabel1.Font.Size := 10
  CancelLabel1.Font.Color := $4B4B4B;

  CancelLabel2:= TLabel.Create(CancelForm);
  CancelLabel2.AutoSize:=False;
  CancelLabel2.Parent:=CancelForm;
  CancelLabel2.Font.Style := [fsBold];
  CancelLabel2.SetBounds(CancelLabel1.Left + (56), ScaleY(42), ScaleY(310), ScaleY(150));
  CancelLabel2.Transparent:=True;
  CancelLabel2.Caption := '     ';
  CancelLabel2.OnMouseDown:=@CancelFormMouseDown;
  CancelLabel2.Font.Name := '微软雅黑';
  CancelLabel2.Font.Color := $4B4B4B;
  CancelLabel2.Font.Size := 9

  CancelLabel3:= TLabel.Create(CancelForm);
  CancelLabel3.AutoSize:=False;
  CancelLabel3.Parent:=CancelForm;
  CancelLabel3.WordWrap := True;
  CancelLabel3.SetBounds(CancelLabel1.Left,CancelLabel1.Top + (45), ScaleY(310), ScaleY(150));
  CancelLabel3.Transparent:=True;
  CancelLabel3.Caption := '本次由mad8834671打包';
  CancelLabel3.OnMouseDown:=@CancelFormMouseDown;
  CancelLabel3.Font.Name := '微软雅黑';
  CancelLabel3.Font.Color := $4B4B4B;
  CancelLabel3.Font.Size := 9
//
  QQLabel := TLabel.Create(CancelForm);
  QQLabel.Parent := CancelForm;
  QQLabel.Left := CancelLabel3.Left
  QQLabel.Top := CancelLabel3.Top + 47
  QQLabel.Caption := 'www.win7new.com';
  QQLabel.Font.Style := [fsUnderline];
  QQLabel.Transparent := True;
  QQLabel.Font.Color := $FFFFFF;
  QQLabel.Font.Name := '微软雅黑';
  QQLabel.Cursor := MyCursor2;
  QQLabel.OnClick := @QQOnClick;
  QQLabel.Font.Size := 9

  QZONELabel := TLabel.Create(CancelForm);
  QZONELabel.Parent := CancelForm;
  QZONELabel.Left := CancelLabel3.Left
  QZONELabel.Top := QQLabel.Top+ 20
  QZONELabel.Caption := 'IOI5201314.QZONE.QQ.COM';
  QZONELabel.Font.Style := [fsUnderline];
  QZONELabel.Transparent := True;
  QZONELabel.Font.Name := '微软雅黑';
  QZONELabel.Font.Color := $FFFFFF;
  QZONELabel.Cursor := MyCursor2;
  QZONELabel.OnClick := @QZONEOnClick;
  QZONELabel.Font.Size := 9

  OKButton := TButton.Create(CancelForm);
  OKButton.Parent := CancelForm;
  OKButton.ModalResult := mrOk;
  OKButton.SetBounds(0, 0, 0, 0);

  ImgApplyChanges(CancelForm.Handle);

  if CancelForm.ShowModal = mrOK then
  begin
  end
end;

//按钮点击事件
procedure NextBtnClick(hBtn:HWND);
begin
WizardForm.NextButton.Click;
end;

procedure CancelBtnClick(hBtn:HWND);
begin
WizardForm.CancelButton.Click;
end;

procedure DirBrowseBtnClick(hBtn:HWND);
begin
WizardForm.DirBrowseButton.Click;
Diredit.Caption:=WizardForm.DirEdit.Text;
//Diredit.Text:=WizardForm.DirEdit.Text;
end;

//协议选框
procedure licenseCheckClick(hBtn:HWND);
begin
if BtnGetChecked(licenseCheck) then
BtnSetEnabled(NextBtn,True)
else
BtnSetEnabled(NextBtn,False)
end;

procedure licenseChecklabelOnClick(Sender: TObject);
begin
BtnSetChecked(licenseCheck, not BtnGetChecked(licenseCheck));
if BtnGetChecked(licenseCheck) then
BtnSetEnabled(NextBtn,True)
else
BtnSetEnabled(NextBtn,False)
end;
 // 脚本由mad8834671 分享
//快捷方式选框
function AutoRun: Boolean;
begin
  Result:= BtnGetChecked(AutoRunCheck);
end;
// 脚本由mad8834671 分享
function Desktop: Boolean;     
begin
  Result:= BtnGetChecked(DesktopCheck);
end;
// 脚本由mad8834671 分享
function StartMenu: Boolean;  
begin
  Result:= BtnGetChecked(StartMenuCheck);
end;
// 脚本由mad8834671 分享
procedure AutoRunLabelClick(Sender:TObject);
begin
  BtnSetChecked(AutoRunCheck, not BtnGetChecked(AutoRunCheck));
end;
// 脚本由mad8834671 分享
procedure DesktopLabelClick(Sender:TObject);
begin
  BtnSetChecked(DesktopCheck, not BtnGetChecked(DesktopCheck));
end;
// 脚本由mad8834671 分享
procedure StartMenuLabelClick(Sender:TObject);
begin
  BtnSetChecked(StartMenuCheck, not BtnGetChecked(StartMenuCheck));
end;
// 脚本由mad8834671 分享
//运行框
procedure Run1LabelClick(Sender:TObject);
begin
  BtnSetChecked(Run1Check, not BtnGetChecked(Run1Check));
end;
// 脚本由mad8834671 分享
procedure Run2LabelClick(Sender:TObject);
begin
  BtnSetChecked(Run2Check, not BtnGetChecked(Run2Check));
end;
// 脚本由mad8834671 分享
//跳过界面
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if (PageID=wpWelcome) or (PageID=wpSelectComponents) then    //跳过组件安装界面
  result := true;
end;

// 脚本由mad8834671 分享
//水纹+鱼
procedure TimerProc2(h: Longword; msg: Longword; idevent: Longword; dwTime: Longword);
begin
	VsyncTop:=VsyncTop+1;
	if VsyncTop>WizardForm.ClientHeight then VsyncTop:=0;
	ImgSetPosition(ImgVsync,-VsyncTop,199,0,0);
	ImgApplyChanges(WizardForm.Handle);
end;
// 脚本由mad8834671 分享
procedure WFDeInit;
begin
KillTimer(WizardForm.Handle,TimerID2);
end;
// 脚本由mad8834671 分享
procedure InitializeWizard();
begin
ExtractTemporaryFile('I.png');
ExtractTemporaryFile('bg01.png');
ExtractTemporaryFile('bg02.png');
ExtractTemporaryFile('bg03.png');
ExtractTemporaryFile('bg04.png');
ExtractTemporaryFile('Close.png');
ExtractTemporaryFile('Button.png');
ExtractTemporaryFile('Button1.png');
ExtractTemporaryFile('Cancel.png');
ExtractTemporaryFile('LOGO.png');
ExtractTemporaryFile('LOGO1.png');
ExtractTemporaryFile('yu.png');
ExtractTemporaryFile('wen.png');
ExtractTemporaryFile('shui.png');
ExtractTemporaryFile('wen1.png');
ExtractTemporaryFile('music.mp3');
ExtractTemporaryFile('music.png');
ExtractTemporaryFile('help.png');
ExtractTemporaryFile('select.png');
ExtractTemporaryFile('MinBtn.png');
ExtractTemporaryFile('MsgDlgBg.png');
ExtractTemporaryFile('progress.png');
ExtractTemporaryFile('progressbg.png');
ExtractTemporaryFile('DialogIcon.png');
ExtractTemporaryFile('CommonRadio.png');
ExtractTemporaryFile('ChangeFolder.png');  
ExtractTemporaryFile('DirEditBackImg.png');
WFButtonFont:=TFont.Create;
ExtractTemporaryFile('cursor.ani');
ExtractTemporaryFile('UpArrow.ani');
cursor := LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani'));
UpArrow := LoadCursorFromFile(ExpandConstant('{tmp}\UpArrow.ani'));
Screen.Cursors[MyCursor1] := UpArrow;
Screen.Cursors[MyCursor2] := cursor;
//WinzardForm
WizardForm.BorderStyle:=bsNone; //去边框 、
WizardForm.OnMouseDown:=@WizardFormMouseDown;
WizardForm.ClientWidth:=516
WizardForm.ClientHeight:=359
WizardForm.Cursor := MyCursor1;
//背景图
WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\bg01.png'),ScaleX(0), ScaleY(0),516,339,True,True);
//关闭按钮
CloseBtn:=BtnCreate(WizardForm.Handle,481,5,30,30,ExpandConstant('{tmp}\Close.png'),3,False);
BtnSetEvent(CloseBtn,BtnClickEventID,WrapBtnCallback(@CloseBtnOnClick,1));
BtnSetCursor(CloseBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
//关于
IsBtn:=BtnCreate(WizardForm.Handle,5,324,30,30,ExpandConstant('{tmp}\i.png'),3,False);
BtnSetEvent(IsBtn,BtnClickEventID,WrapBtnCallback(@AboutButtonOnClick1,1));
BtnSetCursor(IsBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
//help
help:=BtnCreate(WizardForm.Handle,5,5,30,30,ExpandConstant('{tmp}\help.png'),3,False);
BtnSetEvent(help,BtnClickEventID,WrapBtnCallback(@helpClick1,1));
BtnSetCursor(help,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
//WizardForm
WizardForm.OuterNotebook.Hide;
WizardForm.Bevel.Hide;
WizardForm.BeveledLabel.Width := 0
WizardForm.BeveledLabel.Height := 0


//其他组件
VsyncTop:=0;
ImgVsync:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\shui.png'),0,0,0,0,False,False);
TimerID2:=SetTimer(0,0,55,WrapTimerProc(@TimerProc2,4));


//
//音乐
  Music:=BtnCreate(WizardForm.Handle,ScaleX(481),ScaleY(324),ScaleX(30),ScaleY(30),ExpandConstant('{tmp}\music.png'),0,True);
  BtnSetEvent(Music,BtnClickEventID,WrapBtnCallback(@MusicClick,1));
  BtnSetVisibility(Music,True);
  BtnSetCursor(Music,GetSysCursorHandle(32649));
  mp3Name:=ExpandConstant('{tmp}\Music.mp3');
  BASS_Init(-1,44100,0,0,0);
  mp3Handle:=BASS_StreamCreateFile(FALSE,PAnsiChar(mp3Name),0,0,BASS_SAMPLE_LOOP);
  BASS_Start;
  BASS_ChannelPlay(mp3Handle,False);
//音乐

//按钮
WizardForm.BackButton.Width:=0;
WizardForm.BackButton.Height:=0;
//下一步
NextBtn:=BtnCreate(WizardForm.Handle,220,240,80,58,ExpandConstant('{tmp}\button.png'),1,False);
BtnSetEvent(NextBtn,BtnClickEventID,WrapBtnCallback(@NextBtnClick,1));
BtnSetFont(NextBtn,WFButtonFont.Handle);
BtnSetFontColor(NextBtn,clWhite,clWhite,clWhite,$B6B6B6);
BtnSetCursor(NextBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
WizardForm.NextButton.Width:=0;
WizardForm.NextButton.Height:=0;
//取消
CancelBtn:=BtnCreate(WizardForm.Handle,110,250,69,30,ExpandConstant('{tmp}\button1.png'),1,False)
BtnSetEvent(CancelBtn,BtnClickEventID,WrapBtnCallback(@CancelBtnClick,1));
BtnSetFont(CancelBtn,WFButtonFont.Handle);
BtnSetFontColor(CancelBtn,clWhite,clWhite,clWhite,$B6B6B6);
BtnSetCursor(CancelBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
WizardForm.CancelButton.Width:=0;
WizardForm.CancelButton.Height:=0;

//程序安装目录
SelectDirLabel := TLabel.Create(WizardForm);
SelectDirLabel.Parent := WizardForm;
SelectDirLabel.Font.Name := '微软雅黑';
SelectDirLabel.Font.Size := 10
SelectDirLabel.Transparent := True;
SelectDirLabel.Font.Style := [fsBold];
SelectDirLabel.AutoSize := False;
SelectDirLabel.Font.Color := clWhite ;
//SelectDirLabel.WordWrap := True;
SelectDirLabel.SetBounds(ScaleX(50), ScaleY(305), ScaleY(300), ScaleY(16));
SelectDirLabel.Caption := ExpandConstant('{cm:SelectDirLabel}');  //控件文字  '#13'
SelectDirLabel.OnMouseDown:=@WizardFormMouseDown;

//浏览
DirBrowseBtn:=BtnCreate(WizardForm.Handle,340,270 ,42,27,ExpandConstant('{tmp}\ChangeFolder.png'),1,False);
BtnSetEvent(DirBrowseBtn,BtnClickEventID,WrapBtnCallback(@DirBrowseBtnClick,1));
BtnSetFont(DirBrowseBtn,WFButtonFont.Handle);
BtnSetFontColor(DirBrowseBtn,Clblack,Clblack,Clblack,$B6B6B6);
BtnSetCursor(DirBrowseBtn,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
WizardForm.DirBrowseButton.Width:=0;
WizardForm.DirBrowseButton.Height:=0;

Diredit:= TLabel .Create(WizardForm);
Diredit.Parent:=WizardForm;
Diredit.AutoSize:=False;
Diredit.Font.Name := '微软雅黑';
Diredit.Font.Size := 10
Diredit.Font.Color := clWhite ;
Diredit.Cursor := MyCursor2;
//Diredit.BorderStyle:=bsNone;
Diredit.Transparent := True;
Diredit.SetBounds(ScaleX(110), 305, ScaleY(315), ScaleY(18));
Diredit.Caption := WizardForm.DirEdit.Text;

//自定义安装选项
ZidingyiLabe := TLabel.Create(WizardForm);
ZidingyiLabe.Parent := WizardForm;
ZidingyiLabe.Font.Name := '微软雅黑';
ZidingyiLabe.Font.Size := 10
ZidingyiLabe.Font.Style := [fsBold];
ZidingyiLabe.Font.Color := clWhite ;
ZidingyiLabe.Transparent := True;
ZidingyiLabe.AutoSize := False;
ZidingyiLabe.WordWrap := True;
ZidingyiLabe.SetBounds(SelectDirLabel.Left+120, 120+87, ScaleY(100), ScaleY(16));
ZidingyiLabe.Caption := ExpandConstant('{cm:ZidingyiLabel}');  //控件文字  '#13'
ZidingyiLabe.OnMouseDown:=@WizardFormMouseDown;

//快捷方式选框
//桌面快捷方式
DesktopCheck:=BtnCreate(WizardForm.Handle,270, 120+87+3, ScaleY(14), ScaleY(14),ExpandConstant('{tmp}\select.png'),1,True);
BtnSetCursor(DesktopCheck,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
DesktopLabel := TLabel.Create(WizardForm);
DesktopLabel.AutoSize:=False;
DesktopLabel.SetBounds(290, 120+87  , ScaleY(98), ScaleX(16));
DesktopLabel.OnClick:= @DesktopLabelClick;
DesktopLabel.Cursor:= MyCursor2;
DesktopLabel.Font.Size := 10
DesktopLabel.Transparent:=True;
DesktopLabel.Font.Name := '微软雅黑';
DesktopLabel.Caption := '创建到桌面';
DesktopLabel.Parent := WizardForm;
DesktopLabel.Font.Color:= clWhite;

PrLabel:=TLabel.Create(WizardForm);
PrLabel.Parent:=WizardForm;
PrLabel.Left:=95;
PrLabel.Top:=232;
PrLabel.Transparent:=True;
PrLabel.Font.Color:= clWhite;

PrLabel1:=TLabel.Create(WizardForm);
PrLabel1.Parent:=WizardForm;
PrLabel1.Left:=35;
PrLabel1.Top:=230;
PrLabel1.Font.Name := '微软雅黑'
PrLabel1.Font.Size := 9
PrLabel1.Font.Color:= clWhite;
PrLabel1.Caption:='正在安装';
PrLabel1.Transparent:=True;

PBOldProc:=SetWindowLong(WizardForm.ProgressGauge.Handle,-4,PBCallBack(@PBProc,4));

//安装完成
FinishedLabel := TLabel.Create(WizardForm);
FinishedLabel.Parent := WizardForm;
FinishedLabel.Font.Name := '微软雅黑';
FinishedLabel.Font.Size := 15
FinishedLabel.Transparent := True;
FinishedLabel.Font.Style := [fsBold];
FinishedLabel.Font.Color:= clWhite;
FinishedLabel.AutoSize := False;
FinishedLabel.WordWrap := True;
FinishedLabel.SetBounds(ScaleX(40), ScaleY(175), ScaleY(300), ScaleY(30));
FinishedLabel.Caption := ExpandConstant('{cm:FinishedLabel}');  //控件文字  '#13'
FinishedLabel.OnMouseDown:=@WizardFormMouseDown;

//运行框
Run1Check:=BtnCreate(WizardForm.Handle,ScaleX(72),ScaleY(210),ScaleX(14),ScaleY(14),ExpandConstant('{tmp}\select.png'),1,True);
BtnSetCursor(Run1Check,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
Run1Label := TLabel.Create(WizardForm);
Run1Label.AutoSize:=False;
Run1Label.SetBounds(ScaleY(95), ScaleY(210), ScaleX(150), ScaleY(14));
Run1Label.OnClick:= @Run1LabelClick;
Run1Label.Cursor:= MyCursor2;
Run1Label.Transparent:=True;
Run1Label.Caption := '立即运行 {#MyAppName}';
Run1Label.Parent := WizardForm;
Run1Label.Font.Color:= clWhite;

Run2Check:=BtnCreate(WizardForm.Handle,ScaleX(62),ScaleY(100),ScaleX(14),ScaleY(14),ExpandConstant('{tmp}\select.png'),1,True);
BtnSetCursor(Run2Check,LoadCursorFromFile(ExpandConstant('{tmp}\cursor.ani')));
Run2Label := TLabel.Create(WizardForm);
Run2Label.AutoSize:=False;
Run2Label.SetBounds(Run1Label.Left, Run1Label.Top + (21), ScaleX(150), ScaleY(14));
Run2Label.OnClick:= @Run2LabelClick;
Run2Label.Cursor:= MyCursor2;
Run2Label.Transparent:=True;
Run2Label.Caption := '启动 腾讯QQ2011';
Run2Label.Parent := WizardForm;
end;
// 脚本由mad8834671 分享
//取消窗口
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:= false;
Cancel:=True;
end;
// 脚本由mad8834671 分享
function StatusMsg(MyMsg: string): Boolean;
begin
Result:= True;
end;
// 脚本由mad8834671 分享
procedure CurPageChanged(CurPageID: Integer);
begin
    BtnSetText(NextBtn,WizardForm.NextButton.Caption);
    BtnSetVisibility(NextBtn,WizardForm.NextButton.Visible);

    BtnSetText(CancelBtn,WizardForm.CancelButton.Caption);
    BtnSetVisibility(CancelBtn,WizardForm.CancelButton.Visible);
    
    BtnSetText(DirBrowseBtn,WizardForm.DirBrowseButton.Caption);
    BtnSetVisibility(DirBrowseBtn,False);

    ImgSetVisibility(SelectDirline,False);
    ImgSetVisibility(Gerenfolderline,False);
    ImgSetVisibility(Zidingyiline,False);
    //文字
    BtnSetVisibility(MinBtn,True);
    BtnSetVisibility(CancelBtn,False);
    BtnSetVisibility(NextBtn,False);
//快捷方式选框
    DesktopLabel.Hide;
    Run1Label.Hide;
    Run2Label.Hide;
    BtnSetVisibility(DesktopCheck,False);
    BtnSetVisibility(Run1Check,False);
    BtnSetVisibility(Run2Check,False);
    Diredit.Hide
    SelectDirLabel.hide
    ZidingyiLabe.hide
    WizardForm.DirEdit.hide
    BtnSetVisibility(DirBrowseBtn2,False);
    WizardForm.ComponentsList.hide;
    WizardForm.DiskSpaceLabel.hide
    FinishedLabel.hide
    PrLabel.hide
    PrLabel1.hide
  if CurPageID = wpWelcome then
    begin
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\bg01.png'),ScaleX(0), ScaleY(0),516,339,True,True);
    end;
  if CurPageID = wpSelectDir then
    begin
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\bg02.png'),ScaleX(0), ScaleY(0),516,339,True,True);
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\DirEditBackImg.png'),ScaleX(140),90,250,130,True,True);
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\LOGO.png'),370,80,100,25,True,True);
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\LOGO1.png'),180,80,165,40,True,True);
    BtnSetVisibility(NextBtn,True);
    WizardForm.NextButton.Caption := '  '
    BtnSetText(NextBtn,'  ');
    SelectDirLabel.show
    ZidingyiLabe.show
    BtnSetText(DirBrowseBtn,WizardForm.DirBrowseButton.Caption);
    BtnSetVisibility(DirBrowseBtn,True);
    BtnSetVisibility(OnlinkBtn,False);
    BtnSetEnabled(OnlinkBtn,False);
    Diredit.show

//快捷方式选框
    DesktopLabel.show
    BtnSetVisibility(DesktopCheck,True); //桌面
    BtnSetChecked(DesktopCheck,True);
    end;
  if CurPageID = wpInstalling then
    begin
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\bg03.png'),ScaleX(0), ScaleY(0),516,339,True,True);
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\DirEditBackImg.png'),ScaleX(140),90,250,130,True,True);
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\LOGO.png'),370,80,100,25,True,True);
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\LOGO1.png'),180,80,165,40,True,True);
    progressbgImg1:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\progressbg.png'),35,261,451,7,True,True);
    progressbgImg:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\progress.png'),0,0,0,0,True,True);
    PrLabel.show
    PrLabel1.show
    
//安装过程灰掉按钮
    BtnSetVisibility(NextBtn,False);
    BtnSetText(NextBtn,'  ');
    BtnSetEnabled(NextBtn,False)
    BtnSetVisibility(OnlinkBtn,False);
    BtnSetEnabled(OnlinkBtn,False);
    end;
    if CurPageID = wpFinished then
    begin
    WizardFormImage:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\bg04.png'),ScaleX(0), ScaleY(0),516,339,True,True);
    Finishedline:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\line.png'),ScaleX(130), ScaleY(55), ScaleY(386), ScaleY(2),True,True);
    FinishedLabel.show
    Run1Label.Show;                //运行框1
    BtnSetVisibility(Run1Check,True);
    BtnSetChecked(Run1Check,True);

    BtnSetVisibility(OnlinkBtn,False);
    BtnSetEnabled(OnlinkBtn,False);

//    Run2Label.Show;
//    BtnSetVisibility(Run2Check,True);  //运行框2
//    BtnSetChecked(Run2Check,False);
    //移动"完成"按钮
    BtnSetVisibility(NextBtn,False);
    BtnSetVisibility(CancelBtn,True);
    BtnSetText(CancelBtn,WizardForm.NextButton.Caption);
    BtnSetEvent(CancelBtn,BtnClickEventID,WrapBtnCallback(@NextBtnClick,1));

    end;
ImgApplyChanges(WizardForm.Handle);
end;
// 脚本由mad8834671 分享
procedure DeinitializeSetup();
begin
//鼠标指向
WFDeInit;
DeleteObject(cursor);
DeleteObject(UpArrow);
BASS_Stop;
BASS_Free;
gdipShutdown;  //背景图
if PBOldProc<>0 then SetWindowLong(WizardForm.ProgressGauge.Handle,-4,PBOldProc);  
end;                                                                    
// 脚本由mad8834671 分享
//安装结束，点"完成"之后运行程序
procedure CurStepChanged(CurStep: TSetupStep);
var
RCode: Integer;
begin
//程序1
if (CurStep=ssDone) and (BtngetChecked(Run1Check)) then
Exec(ExpandConstant('{app}\AngryBirdsSeasons.exe'), '', '', SW_SHOW, ewNoWait, RCode);
//程序2
if (CurStep=ssDone) and (BtngetChecked(Run2Check)) then
Exec(ExpandConstant('{app}\Bin\QQ.exe'), '', '', SW_SHOW, ewNoWait, RCode);
end;

